home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993…ch: Other People's Memory / ADC Developer CD (1993-03) (''Other People's Memory'')_iso / Dev.CD Mar 93.iso / Technical Documentation / Sample Code / DTS_SCSI Code (In Development) / DTS_SCSI_Format.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-15  |  5.1 KB  |  189 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        DTS_Format.h
  3.     
  4.     
  5.     
  6.     
  7.     
  8.     Unfortunately, no matter how long awaited, it's still not done.  In fact, this
  9. isn't even a release- this is just an image of the code taken in the middle of
  10. development.
  11.  
  12. THIS CODE DOES NOT WORK AS A WHOLE.  MUCH OF IT IS BUGGY AND / OR INCOMPLETE.
  13. YOU WOULD HAVE TO BE ABSOLUTELY INSANE TO USE ANY OF THIS CODE IN YOUR
  14. PROJECT WITHOUT EXTENSIVE THOUGHT, DEBUGGING AND TESTING.
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.     Contains:    global types, constants, and function prototypes
  22.  
  23.     Written by:    Kent Sandvik
  24.  
  25.     Copyright:    © 1991 by Apple Computer, Inc., all rights reserved.
  26.  
  27.     Change History (most recent first):
  28.  
  29.                  07/21/92   ckd     added define for SCSICmd_ReadCap
  30.                  04/24/92   ckd     added structs used by PartitionCurrentDevice()
  31.                  04/21/92    khs        added changes from code review
  32.                  03/14/92    BJS        changed header, added to project
  33.                  10/19/91    khs        first version
  34.  
  35.     To Do:
  36. */
  37.  
  38. #ifndef _DTS_FORMAT_
  39. #define _DTS_FORMAT_
  40.  
  41. #ifndef __TYPES__
  42. #include <Types.h>
  43. #endif
  44.  
  45. #ifndef __SCSI__
  46. #include <SCSI.h>
  47. #endif
  48.  
  49. #ifndef __DTS_SCSI_IO__
  50. #include <DTS_SCSI_IO.h>
  51. #endif
  52.  
  53. // Error values *** need better values for some of these!
  54. #define kNoOtherValidDrives (-1)
  55.  
  56. // An invalid SCSI id.
  57. // *** I wanted this to be "const SCSIAddress kInvalidDevice = -1;" but the compiler choked.
  58. #define kInvalidDevice        (-1)
  59. #define kPartitionTooSmall    (-2)
  60.  
  61. // Number of blocks we reserve for the driver 
  62. // (Right now it is only a few, but this way we have room to grow)
  63. #define kDriverSpace 20
  64.  
  65. // Used to issue a read capacity command to device to find
  66. // capacity (size) of the disk.  
  67. #define SCSICmd_ReadCap 0x25
  68.  
  69. // Number of partitions on the drives we format 
  70. // (The driver, the hfs partition, and the partition map itself)
  71. #define kPartitionCount 3
  72.  
  73. //
  74. // Public function prototypes
  75. // These are called by the formatting routines in DTS_SCSI_Formatter.c
  76. //
  77.  
  78. //
  79. // Get the ID of the current device; return kInvalidDevice if
  80. // we haven't found a suitable device.
  81. // *** eventually, get the volume name if it has one!
  82. //
  83. extern SCSIAddress CurrentDevice();
  84.  
  85. //
  86. // Set the three strings used to identify one of our devices.
  87. //
  88. extern void SetValidationInfo(Str255 vendorString, Str255 productString, Str255 revisionString);
  89.  
  90. //
  91. // Is this device run by no driver, someone else's driver, a current
  92. // version of our driver, or an old version of our driver? 
  93. //
  94. typedef enum TDriverKind { kNoDriver, kDifferentDriver, 
  95.                            kOurCurrentDriver, kOurOldDriver} TDriverKind;
  96. extern TDriverKind DriverKind(SCSIAddress device);
  97.  
  98. //
  99. // Get the volume reference number and name of the volume mounted on this
  100. // SCSI device (if any). Assumes that we've already checked to see that
  101. // this device has some version of our driver controlling it.
  102. //
  103. // Return 0 if no volume mounted.
  104. //
  105. extern short VolumeFromDevice(SCSIAddress device, Str255 name);
  106.  
  107. //
  108. // Find the next eligible device in the chain, and note its SCSI ID in gCurrentDevice.
  109. // Return 0 if we found a different one than the current one, or:
  110. //        kNoOtherValidDrives: if the only drive we could find is the current one.
  111. //        *** some low-level error: if we couldn't find any valid drives, or if we
  112. //                            couldn't communicate over the bus at all.
  113. //
  114. extern OSErr NextEligibleDevice();
  115.  
  116. //
  117. // Format the current SCSI device.
  118. // This routine assumes that the current device is one of our devices, and that it's OK with
  119. // the user that we trash it. The caller should put up whatever message is appropriate
  120. // ("Formatting…") before calling this routine. 
  121. //
  122. extern OSErr FormatCurrentDevice();
  123.  
  124.  
  125. // Format a particular SCSI device. This routine could be used to define a special
  126. // SCSI address and format the existing driver at this address. FormatCurrentDevice
  127. // is calling this lower level routine
  128.  
  129. extern OSErr FormatSCSIDevice(SCSIAddress device);
  130.  
  131. // Test the current SCSI device.
  132. // This routine assumes that the current device is one of our devices. The caller should 
  133. // put up whatever message is appropriate ("Testing…") before calling this routine. This 
  134. // routine will put up and spin a busy cursor (*** eventually).
  135.  
  136. extern OSErr TestCurrentDevice();
  137.  
  138. // Write partitioning information to the current device. 
  139. // Assumes that the device has been successfully formatted.
  140.  
  141. OSErr PartitionCurrentDevice();
  142.  
  143. // Install a new driver on top of the old driver on the current device.  Assumes
  144. // the drive has already been formatted and partitioned.
  145.  
  146. OSErr UpdateCurrentDevice();
  147.  
  148. //
  149. // Mount the newly formatted and partitioned device.
  150. // 
  151. OSErr MountCurrentDevice();
  152.  
  153. //
  154. // Unmount the soon-to-be formatted device.
  155. // 
  156. OSErr UnmountCurrentDevice();
  157.  
  158. //
  159. //    Check a SCSI device
  160. //
  161. OSErr CheckSCSIDevice(SCSIAddress device);
  162.  
  163. //
  164. //    Do a low level Test Unit Ready call to the SCSI Device
  165. //
  166. OSErr SCSITestUnitReady(SCSIAddress device);
  167.  
  168. //
  169. // Do a low level INQUIRY call to the SCSI Device
  170. //
  171. OSErr SCSIDoInquiryCommand(SCSIAddress device);
  172.  
  173. // 
  174. // Do a low level READ CAPACITY call to the SCSI Device
  175. // 
  176. unsigned long SCSIDoReadCapacityCommand(SCSIAddress device);
  177.  
  178. //
  179. // Get the volume name of the SCSI device
  180. //
  181. Str31 SCSIGetVolumeName();
  182.  
  183. //
  184. // Test if the drive is a valid drive for our format/dev driver code
  185. //
  186. OSErr SCSIMatchDriveInfo(char* vendor, char* product, char* revision);
  187.  
  188. #endif _DTS_FORMAT_
  189.